package com.atguigu.spzx.spzx.model.vo.common;

import lombok.Data;

@Data
public class Result<T> {
    private Integer code;
    private String message;
    private T data;
    private Result(){}

    public static<T> Result build(Integer code,String message,T data){
        Result result = new Result<>();
        result.code =code ;
        result.message = message;
        result.data =data;
        return result;
    }

    public static<T> Result ok(){
        return build(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMessage(),null);
    }

    public static<T> Result error(){
        return build(ResultCodeEnum.LOGIN_ERROR.getCode(), ResultCodeEnum.LOGIN_ERROR.getMessage(),null);
    }
    public Result message(String message){
        this.message =message;
        return this;
    }
    public Result code(Integer code){
        this.code =code;
        return this;
    }
    public Result data(T data){
        this.data =data;
        return this;
    }
}
